package com.guigu.liuzhireng.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.liuzhireng.mapper.SyslogsMapper;
import com.guigu.liuzhireng.pojo.PageVo;
import com.guigu.liuzhireng.pojo.Syslogs;
import com.guigu.liuzhireng.service.SyslogsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SyslogsServiceImpl implements SyslogsService {
    @Autowired
    SyslogsMapper mapper;


    @Override
    public PageVo<Syslogs> Page(Syslogs syslogs, int num, int size) {
        PageHelper.startPage(num,size);
        List<Syslogs> list = mapper.queryAllSyslogs(syslogs);
        PageInfo<Syslogs> pageInfo = new PageInfo<>(list);
        PageVo<Syslogs> pageVo = new PageVo<>();
        pageVo.setTotal(pageInfo.getTotal());
        pageVo.setRows(pageInfo.getList());
        return pageVo;
    }

    @Override
    public int insert(Syslogs record) {
        return mapper.insert(record);
    }
}
